<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>创客手机网站</title>
  <script src="/wap/js/flexible.js"></script>
  <script src="/wap/js/jquery-3.2.1.min.js"></script>
  <script src="/wap/js/util.js"></script>
  <link rel="stylesheet" href="/wap/css/style.css">
  <style>
    html {
      background: #f3f5f7;
    }
  </style>
</head>
<body>
  <div id="detail">
    <div class="detail__change" onclick="window.location.href='{{ route('wap.index.index') }}'">切换账号</div>
    <div class="user">
      <div class="user__top clearfix">
        <div class="user__top__avatar">
          @if($data->head_image_path)
            <img src="{{ $data->head_image_path }}" alt="">
          @else
            <img src="/wap/image/logo.png" alt="">
          @endif
        </div>
        <div class="user__top__info">
          <div class="info__name">{{ $data->name }} ID:<span style="color: red">{{ $data->id }}</span></div>
          <div class="info__type">@if($data->user_type==1) 创客 @else 城市合伙人 @endif</div>
        </div>
      </div>
      <div class="user__bottom clearfix">
        <div class="box user__bottom__points">
          <div class="value">{{ $data->integral }}</div>
          <div class="type">我的积分</div>
          <div class="bor-gray"></div>
        </div>
        <div class="box user__bottom__reg">
          <div class="value">{{ $data->registered_currency }}</div>
          <div class="type">注册币</div>
          <div class="bor-gray"></div>
        </div>
        <div class="box user__bottom__reg">
          <div class="value">{{ ($data->entrepreneurship_achievement+$data->chuangheng_achievement+$data->director_achievement)/10000 }}万</div>
          <div class="type type-btn" onclick="location.href='/wap/index/achievement/{{ $data->id }}'">我的业绩</div>
        </div>

        <div class="user__bottom">
          <div class="box user__bottom__points">
            <div class="value">{{ $data->freeze_integral }}</div>
            <div class="type">待结算积分</div>
            <div class="bor-gray"></div>
          </div>
          <div class="box user__bottom__reg">
            <div class="value">{{ $data->freeze_registered_currency }}</div>
            <div class="type">待结算注册币</div>
            <div class="bor-gray"></div>
          </div>
          <div class="box user__bottom__reg" onclick="location.href='/wap/index/refereeList/{{ $data->id }}'">
            <div class="value">{{ $referee_num }}</div>
            <div class="type type-btn">我推荐的</div>
          </div>
        </div>
      </div>
    </div>
    <div class="cell" style="margin-top: 0.27rem;" onclick="showPopup()">
      <span>修改昵称</span>
      <img src="/wap/image/arrow_gray.png" class="arrow">
    </div>
    <div class="cell" onclick="location.href='/wap/index/transferAccount/{{ $data->id }}'">
      <span>转移账号</span>
      <img src="/wap/image/arrow_gray.png" class="arrow">
    </div>
    <!--<div class="detail__btn" onclick="withdraw({{ $data->id }})">申请积分提现</div>-->

    <div class="shadow" style="display: none;">
      <input type="hidden" name="_token" value="{{csrf_token()}}">
      <div class="popup">
        <div class="title">修改昵称</div>
        <input type="text" class="popup-input" id="nickName">
        <div class="btn-list">
          <div class="btn-item-bor"></div>
          <div class="btn-item" onclick="showPopup()">
            取消
          </div>
          <div class="btn-item c-e60012" onclick="success()">
            确定
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

<script>
    function withdraw(user_id) {
        window.location.href = '/wap/index/withdraw/'+user_id;
    }
    function success(){
        var id = '{{ $data->id }}';
        var nickName = $('#nickName').val();
        var csrf_token = $('input[name="_token"]').val();
        if(!nickName){
            toast('未输入新昵称！',2000);
            return false;
        }
        $.ajax({
            type: 'post',
            url: '{{ route('wap.index.detail') }}',
            data: {'id':id,'nickName':nickName,'_token':csrf_token},
            dataType: "JSON",
            async: false,
            success: function (res) {
                if(res.status=='FAIL'){
                    toast(res.message,2000);
                }else{
                    toast('修改成功！',2000);
                    location.reload();
                    $('.shadow').toggle();
                }
            },
            error: function (res) {
                console.log(res, 'error');
            }
        });
    }
    function showPopup(){
        $('.shadow').toggle();
    }
</script>